$(function(){
	$("#submit").click(function() {
		var jsonuserinfo = $.toJSON($('#form').serializeObject());
		jQuery.ajax( {
			type : 'POST',
			contentType : 'application/json',
			url : rootPath+'/user/add',
			data : jsonuserinfo,
			dataType : 'json',
			success : function(data) {
				if (data && data.success == "true") {
					alert("新增成功！");
				}else{
					alert("新增失败！");
				}
			},
			error : function(data) {
				alert("error")
			}
		});
	});
});
$.fn.serializeObject = function() {
	var o = {};
	var a = this.serializeArray();
	$.each(a, function() {
		if (o[this.name]) {
			if (!o[this.name].push) {
				o[this.name] = [ o[this.name] ];
			}
			o[this.name].push(this.value || '');
		} else {
			o[this.name] = this.value || '';
		}
	});
	return o;
};